using UnityEngine;
using UnityEngine.Networking;

public class Car : Vehicle
{
	public CarControl car;

	private Vector2 inputTemp;

	private bool brakeTemp;

	public override void Start()
	{
		Audiosource = GetComponent<AudioSource>();
		car = base.gameObject.GetComponent<CarControl>();
		base.Start();
	}

	public override void Drive(Vector2 input, bool brake)
	{
		driving(new Vector3(input.x, input.y, 0f), brake);
		base.Drive(input, brake);
	}

	public void driving(Vector3 input, bool brake)
	{
		inputTemp = input;
		brakeTemp = brake;
		incontrol = true;
		if (input.x == 0f && input.y == 0f && !brake)
		{
			incontrol = false;
		}
	}

	public override void Update()
	{
		if (base.isServer)
		{
			if (incontrol && (bool)car)
			{
				car.Controller(new Vector2(inputTemp.x, inputTemp.y), brakeTemp);
			}
			if ((bool)car)
			{
				car.StartEngine(hasDriver);
			}
		}
		base.Update();
	}

	private void UNetVersion()
	{
	}

	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		bool flag = base.OnSerialize(writer, forceAll);
		bool flag2 = default(bool);
		return flag2 | flag;
	}

	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		base.OnDeserialize(reader, initialState);
	}
}
